# ==================================
# --*-- coding: utf-8 --*--
# @Time    : 2021-11-09
# @Author  : 微信公众号：K哥爬虫
# @FileName: replace_js.py
# @Software: PyCharm
# @describe: 混淆还原小脚本
# ==================================


# 以实际列表为准，要和 fm_old.js 里的列表一致
item = ['$super', 'num', 'D', 'mac os', 'zxHLIXE7juh9iFplePUaldxaz6HLanwh', 'wr', 'zPHpanwXjOPFHq7FMZUEbX', 'outerHTML', 'log', 'pageInfo', 'all', 'getElementById', 'gecko', 'enc', 'partnerDetectUrl', 'Base64', 'iframe', 'Chrome', 'xAEv', 'S', 'Segoe UI Symbol', 'hSHQaIEGREhHYp7A', 'Base', 'l', 'rPme', '_invSubKeys', '; expires=', 'documentElement', 'Comic Sans MS', 'netscape', 'ie', 'jsDownloadedTime', 'object', 'Lucida Fax', 'zPHda1EGjlPIHx7FeQCfbp', 'zoom', 'Verdana', '_bbxtimestamp', 'onload', '?platform=3', 'keys', 'E', 'zRzjaKw8Ru', 'value', 'getTime', 'initCookie', 'x', 'style', 'device_version', '&i=', 'getUniformLocation', 'amap', 'bAws', '8.0', 'exec', 'Segoe UI Light', '=', 'text-align-last', 'device-version', 'isFirefox', 'call', 'cookieStore', '?', 'insertBefore', '_data', '&appName=', 'enabled', 'script', 'Gult', 'MicroMessenger', 'stack', 'TrackEvent', 'zIHlanwhRIr9Y3pYMQ', 'gesture', 'monospace', 'zVzDIoxXjuPSGM7FePU5', 'indexedDB', 'callSelenium', 'shaderSource', 'q652mrpq0k', 'zIzLanEeRLhwYO71eHUEb6xHhSHv', 'navigator', 'mozRTCPeerConnection', 'Cipher', 'via', 'MSIE (\\d+\\.\\d+);', 'Shockwave Flash', 'on', 'Object.keys called on non-object', 'src', '&osVersion=', 'target', '20030107', 'Palatino', '_x64Rotl', '_x64LeftShift', 'LINUX', 'z0HLINOFRmPr', 'ios', 'CHROME', 'useSid', 'getTimezoneOffset', 'Lucida Handwriting', 'name', 'UNMASKED_RENDERER_WEBGL', 'Pkcs7', 'split', 'createBuffer', 'addHandler', '__BROWSERTOOLS_DOMEXPLORER_ADDED', 'browser', 'userAgent', 'zVzLaNELjKrFYO71MQUEJpfj', 'Lucida Calligraphy', 'jsonCallback', 'presto', 'fulfilled', '#069', 'keydown', 'kdf', 'Safari', 'screen', 'w3', '_utf8_decode', 'z1HdawEcjuhiGPqYMQCpbKx9z0', 'wk', 'this is null or not defined', 'Lucida Sans', 'GEwr', 'ontouchstart', 'dp', 'zRzLINEGRVQqY37bMQUo', 'callPhantom', 'jTimeout', 'tdtest', 'IPHONE', 'UNMASKED_VENDOR_WEBGL', 'base64s', 'h', 'MS Gothic', '_ks', 'index', 'zPHpanwXjOPFHP7aoQUiJgxmi10wkExeRLPSY371ey', 'symbol', 'ANDROID', 'vendor', 'hasOwnProperty', 'https://fp.tongdun.net', 'get', 'G', 'Century Schoolbook', 'cookieHandler', 'qhjc', 'ctrlKey', 'getParameter', 'zPHlaMECjzhriy71eTUpbXxIzS', 'screenLeft', 'salt', 'webkitOfflineAudioContext', 'RIMTABLET', 'appName', 'Geneva', ' OPR/', 'indexDB', 'floor', 'partnerSendSwitch', 'getBattery', '_xid', 'keyWords', '(', 'p=', 'qrkd', 'enableVertexAttribArray', '-&-', 'msBattery', 'zVzDIoOcjzhiYOplNGUEJqfgz6Hlan', 'id', '_', 'webdriver', 'plugins', 'referer', '/web/ub.png', 'rejected', 'createElement', '_t16', 'version', 'getExtension', 'PKzx', 'WEBOS', '?u=', 'toDataURL', '_DEC_XFORM_MODE', '__wxjs_environment', 'status', 'j', 'C', 'timestamp', 'onFulfilled', 'StreamCipher', 'Hex', 'alipay', '_callback=', 'toLowerCase', 'fpNetHost', 'replace', 'allow-scripts', 'M', 'altKey', 'trident', 'qDej', 'O', 'Array.prototype.indexOf() - can\'t convert `', 'indexOf', 'Tahoma', 'P', '&browserVersion=', 'app_name', 'test', 'put', '/fp3/profile.json', 'EvpKDF', 'availHeight', 'MSIE ([0-9]{1,}[.0-9]{0,})', 'charging', 'IPAD', 'vertexPosAttrib', 'metaKey', 'true', 'Arial Black', 'mousemove', '_des2', '-webkit-hyphens', 'o', '4enw49pim03', 'Microsoft Internet Explorer', 'webkitAudioContext', 'readPixels', 'dec', 'Pgwz', 'edit', '_xformMode', 'IE', 'AudioContext', 'zsHpINELRBhriG7AeqUDJgxs', 'Elzt', 'charAt', 'detachEvent', 'ig', 'width', 'splice', 'A', 'yourip', '&os=', 'ABCDEFGHJIKLMNOPQRSTUVWXYZ', 'idf', 'readwrite', 'zNHpanwGjBhLYMpbMzCpbFft', '_unhandledRejectionFn', 'u', 'detect', 'timeout', ' is not a function', 'OpenSSL', 'quota', 'mac', 'screenX', 'Wingdings', 'N', 'RTCPeerConnection', 'Latin1', 'ipod', '_keyStr', 'detectEthernet', 'Lucida Console', 'xiamenair', 'getItem', '_utf8_encode', 'hPHjIXEGjuhiiG7AeGCf', 'Calibri', '/v3/get_black_box.js', 'fmb', 'pad', 'rgba(255,255,255,1)', 'bot', 'zJHpanEFRuhLYx7A', 'TripleDES', 'L', 'cssText', ',', 'availWidth', 'q', ';', '_lBlock', '~/', 'position', 'zPHpanwXjOPF', 'toLocaleString', '_x64Add', 'z6HCanEGRVrRYy7FeyUoJg', 'BlockCipher', 'win', 'setDate', 'MSIE', 'Android.*(wv|.0.0.0)', 'iPhone', 'K', 'Helvetica Neue', 'detectSwitch', 'hash128', 'shiftKey', 'MAC', 'IPOD', 'vertexAttribPointer', '*', 'substring', 'Times', 'gk', 'protocol', 'compatible', 'Z', '&browser=', 'Century', 'invoked', 'webkit', 'touchstart', 'requestPermission', ' is not iterable(cannot read property Symbol(Symbol.iterator))', 'font', 'length', 'token_id', 'absolute', 'objectStoreNames', 'gwsF', 'span', 'documentMode', 'c', 'a', '_x64Multiply', 'toString', 'start', 'TDpx', 'display', 'pxy', 'sin', 'compileShader', '&occurTime=', '$1', 'wsHost', 'WordArray', 'onsuccess', 'Device fingerprint request send successfully, token_id: ', 'msie', 'mobile', 'BLACKBERRY', 'g', 'Segoe Print', 'bgMG', 'w', 'Webkit', 'level', 'sort', 'localStorage', 'ubid', 'chrome', 'string', 'td_ua', 'cdu', 'CLkC', 'k', '\'WebSocket\' is undefined', 'sigBytes', 'staticHost', 'detectUrl', 'transaction', 'gCcJ', 'OPERA', 'FLOAT', 'STATIC_DRAW', 'linkProgram', 'hyhbgqbaxi6', 'ipad', 'tcpHost', 'productSub', 'CSS', 'FRAGMENT_SHADER', 'maxChannelCount', 'iterations', 'zJHpanEFRuhLYx7AMN', 'offsetHeight', 'newValue', 'taobao', 'zNzjkIEkRUQIYOpAeNUoK7xiz6HCINwe', 'IOS', '_x64Xor', 'ch', 'iphone', 'match', 'input', 'uc', '_phantom', '#f60', 'prlt87lwxvm', 'iterator', 'isEdge', 'addres', 'removeChild', 'unknown', 'chromeos', '_des1', 'initialized', '|', 'document', 'http://', 'hczmaKxeRLPSY371ey', 'kPfK', ', ', '_k16', '_handled', 'https://bugly.tongdun.net/bugly/errorCollect/v1.png', 'Utf8', 'f', 'h0HLaXEFjCQFGPple4U5bE', '_cipher', 'set', '0123456789', 'https://xx.com', 'HzEu', 'TRIDENT', 'task', 'Wingdings 2', 'uniform2f', 'isTrusted', 'abs', 'static.fraudmetrix.cn', 'WEBGL_debug_renderer_info', 'MS Reference Sans Serif', 'fontFamily', 'aomygod', 'ltx71', 'spider', 'webos', 'touchmove', 'addEventListener', 'storage', '_k41', 'createShader', 'reCheckCookie', 'Times New Roman PS', 'map', 'WEBKIT', 'error', '2d', 'HmacMD5', 'major', 'Cambria', 'isBlink', 'Georgia', '_sz', 'TOUCHPAD', 'deleted', 'setMonth', 'PRESTO', '未定义', 'result', '-', 'jsonUrl', 'BADA', 'StyleMedia', 'sKrB', '&v=', 'webkitRTCPeerConnection', 'zczwaMwFRIhrGZHSeTU5bEfIzVHKaw', 'ct', 'offsetUniform', 'zJHlaKEkRLhwYO71', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 'hPzQIKwhjuhDiG7eeqUDJFxmz0HL', 'h1zjawwrtOhqYy71MQ', 'getError', 'toUpperCase', 'F', 'FDxu', 'wbvNtP9DRhv8AItE4pgJIHT+k8otjqWtQFKG7tqOS4VtrWerxRtG2w6341/sgCNL', '&errorType=', 'ywwE', 'zPzjIKEkRLPIGZ7FeaCEJgxI', 'hSHlJKwhRVhwYp79NNCfJqxNzsHK', 'propertyIsEnumerable', 'position:absolute !important; z-index:-9999 !important; visibility:hidden !important', 'fontSize', 'onerror', 'zJMu', 'fmData', '14px \'Arial\'', 'tIndex', 'valueOf', 'DES', 'MS PGothic', 'Arial MT', 'getAttribLocation', 'Android', 'token', 'changedTouches', 'normal', 'hPzDawEejzhLYG7lMaUeJEfgz1zw', 'origin', 'h0HQaNwhjU', 'z1HCIwEcjuPSYSpbezefbFfZz6HjawweSIPIGZ7FeqUD', 'add', 'txLj', '[', 'type', '_value', '@script', 'left', '_des3', 'A promise cannot be resolved with itself.', 'MYRIAD', 'onicecandidate', 'debug', 'zding_', 'number', 'zVzDIoOejKhIYyH1eTUabF', 'hasher', 'W', 'Garamond', '', 'removeEventListener', 'chargingTime', 'zbHLa1EFjUPI', 'it', 'canSetSearchEngine', 'encode', '1234567890', '"function log() {\\n    [native code]\\n}"', 'candidate', 'MSPointerEvent', 'screenTop', 'n', 'prototype', 'complete', 'getOwnPropertyDescriptor', '_minBufferSize', 'Lucida Sans Unicode', 'R', 'Ebdl', 'webkitPerformance', 'channelCountMode', 'zPHda1EGjlPIiY7Ae4UDbpfj', 'resolve', 'blackberry', 'cqhk', 'precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}', 'getElementsByName', '&', 'J', '[object SafariRemoteNotification]', 'cub', 'lib', 'https://fptest.fraudmetrix.cn/partnerDetect.json', 'iceServers', '/', 'queryUsageAndQuota', 'iUrl', 'CipherParams', 'zVzcaQELjCrRYy7FeyUoJg', 'offsetWidth', 'Alipay', 'Object', '_fmOpt.token is blank, please set the value of _fmOpt.token and try again!', 'LAjt', 'Segoe UI', 'webkitTemporaryStorage', 'not a function', 'micromessage', 'MJxC', 'slice', 'Lucida Bright', 'join', 'os', 'event', 'fp.fraudmetrix.cn:9090', 'unload', 'getElementsByTagName', 'remove', 'ejmK', 'ARRAY_BUFFER', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', 'min', 'body', 'Bitstream Vera Sans Mono', 'toLocaleLowerCase', '/FreshCookieRequest/fresh.json', 'battery', '/fp/detect.json', 'partnerFpUrl', 'height', 'onreadystatechange', 'check', ']', 'change', 'MD5', '1', 'Opera', 'onunload', 't', 'toGMTString', 'caller', 'Microsoft Sans Serif', '_Selenium_IDE_Recorder', 'https:', 'reverse', 'Mozilla', 'U', 'onRejected', 'hPHjIXEGjuhiHP7aMr', 'msPerformance', 'zPHvawEejqPqY371eQUeJE', 'X', 'Trident', 'forEach', 'concat', 'isGecko', 'webkitIndexedDB', '__IE_DEVTOOLBAR_CONSOLE_COMMAND_LINE', 'Hasher', 'miniprogram', 'hSHlIwEejUQFGyp2MrUeJqfj', 'readyState', 'numItems', 'targetTouches', 'zbHpIXEhRthLGZ7AoNUeb6xgh1zwIXEGjlhFG3', 'ub', '_immediateFn', '72px', '~/=', 'keywords', 'itemSize', 'allSettled', 'Arial Unicode MS', '__defineGetter__', 'Impact', 'Gecko', 'createObjectStore', 'zPHda1EGjlPIi37b', '_t41', 'touchend', 'openDatabase', 'vertexPosArray', 'boolean', 'Lucida Sans Typewriter', 'Q', 'zVzcaQELjCQqY37bMQUo', 'hPzQanwhjOPRiyplMaUeJq', 'Courier', 'createDataChannel', 'mediaDevices', 'linux', '_fmdata', 'm', 'DHDD', '_selenium', '_rBlock', '_fmaa', 'partnerCode', '_prevBlock', 'attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}', 'WINNDOWS', 'Uburl', 'createAnalyser', 'h0HLaXEFjCQHYK7blz', 'Promise.all accepts an array', 'userAgent:', 'stringify', 'window', '0', 'mtgC', 'crios', 'zEwr', 'opera', 'mmmmmmmmmmlli', 'contains', 'numberOfOutputs', 'CHROMEOS', 'jmks', 'dischargingTime', 'abcdefghigklmn', 'mkcK', 'onmessage', 'none', 'isSafari', 'z', 'head', 'https://fptest.fraudmetrix.cn/partnerProfile.json', 'oyo', '; domain=', 'z1zmaWOLRm', 'createProgram', '&h=', 'https://fp.fraudmetrix.cn', 'defineProperty', '00000000', 'getImageData', 'Arial Hebrew', 'referrer', '_ENC_XFORM_MODE', 'Palatino Linotype', '-9999px', 'attrVertex', 'createEvent', 'mouseup', 'Firefox', 'decode', 'SILK', 'android', 'r', 'contentWindow', 'Malformed UTF-8 data', 'Edge', 'HpMx', 'Courier New', 'Consolas', 'tdIframe', 'mozIndexedDB', 'shift', 'isWebkit', 'T', 'location', '_deferreds', 'd', 'canvas', 'TEMPORARY', '&partnerCode=', 'estimate', '(iPhone|iPod|iPad)(?!.*Safari/)', '^^', 'bindBuffer', 'p', 'Mac OS', 'partner', 'format', 'experimental-webgl', 'uwCb', 'values', 'fillText', '\\', 'BlockCipherMode', 'Possible Unhandled Promise Rejection:', 'WINDOWSPHONE', 'top', 'InstallTrigger', 'uniformOffset', 'numberOfInputs', 'compute', 'bada', '` to object', 'then', 'webkitRequestFileSystem', 'apply', '.', 'htHdIwEFjzhiGMqYMQCpbKx9z0', '"function log() { [native code] }"', 'pTimeout', 'open', 'keyup', 'appendChild', 'durations', 'isIE', 'useProgram', 'key', 'z6HCanEGRVQqY37bMQUo', 'move', 'promise', 'http://fp.fraudmetrix.cn', 'textBaseline', 'userData', 'i init ok', 'random', 'fpWebDB', 'page:', 's38huiupo1g', 'abcdefghjiklmnopqrstuvwxyz', 'filename', 'MS Sans Serif', 'Promise.race accepts an array', 'UC', 'v', 'imgLoaded', ')', '12345678', 'attachShader', 'frameElement', 'drawArrays', 'PvtK', 'ErdG', 'getContext', 'success', 'y', 'MS Serif', 'race', 'phantomjs', 'orientation', '_fmOpt', 'e', 'Y', 'H', 'windows', 'webgl', 'downkey', 'PbrD', 'device_type', 'mousedown', 'zSHLIDELjIhriK7AeLUeJqfN', 'PkAF', 'undefined', '_state', 'LIEBAO', 'blackBoxType', '\n', 'CrOS', 'title', 'fromCharCode', 'TRIANGLE_STRIP', 'I', 'usage', '=; domain=', 'reject', 'Promises must be constructed via new', 'deviceInfo', '&sdkName=cn.tongdun.web', 'ucapi', 'ongestureend', 'onupgradeneeded', 'opr', 'ethernet', 'unpad', '_key', '_x64Fmix', 'pushNotification', 'VERTEX_SHADER', 'mozBattery', 'Arial Rounded MT Bold', 'enumerateDevices', 'loaded', 'HMAC', 'keyPath', 'zVzDIoO7jOhDYy', '_nDataBytes', 'rimtablet', 'MOZILLA', 'WebView', 'setLocalDescription', 'zVzLaNELjKQFGPple4U5bE', 'h1zjawwrtChLYp79MzUibExI', 'firefox', 'init', 'sans-serif', 'gbCC', 'sessionStorage', 'TouchEvent', 'desktop', 'PasswordBasedCipher', 'fillStyle', 'Constructor', 'message', 'createOffer', 'fpHost', 'rtcAvailable', 'f736mgcni9c', 'touchpad', 'zcHpINwhjuPSG3', 'RGBA', 'getCookie', 'unable to locate global object', 'htHdIwEFjzhiGM', 'href', 'alphabetic', 'msIndexedDB', 'UNSIGNED_BYTE', 'words', 'innerHTML', 'platform', 'standalone', 'BufferedBlockAlgorithm', 'addons', 'GECKO', 'decryptBlock', 'substr', 'Wingdings 3', 'reason', 'cfg', 'mod', ' ', 'zRzLINEGRVrRYy7FeyUoJg', 'channelInterpretation', 'SAFARI', 'LUCIDA GRANDE', 'now', 'cookie', 'private', 'firstChild', 'o8gm8qu97as', 'url', 'text-rendering', 'SerializableCipher', 'postMessage', 'fpflash.fraudmetrix.cn', 'HTMLElement', 'catch', 'webkitBattery', 'timer', '; path=/', 'finally', 'DeviceMotionEvent', 'sandbox', '&productType=2', 'tokens', 'dingtalk', '__nightmare', 'web', 'serif', 'upkey', 'function', 'initStorage', 'base64_map', 'Cambria Math', 'warn', 'Times New Roman', 'screenY', '_mode', 'paramz', 'SyntaxError', 'fpCache', 'can\'t find _fmOpt', 'bufferData', 'Trebuchet MS', 'itsgonnafail', 'B', 'keyCode', 'Arial Narrow', 'constructor', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 'CBC', 'safari', 'Comic Sans', 'reduce', 's', 'isOpera', 'ua', 'performance', 'Book Antiqua', 'removeItem', 'push', 'algo', 'objectStore', 'https://', 'data', 'cookieEnabled', 'UCNewsJSController', 'attachEvent', 'mozilla', 'Andale Mono', 'removeHandler', 'fp.fraudmetrix.cn', 'device_name', 'blackBox', '0.0.0.0', 'DOLFIN', 'resize', 'V', '_subKeys', 'h77umrlknir', '?period=switchDomain&cookie=', 'fl', 'channelCount', 'zufs', 'checkStatus', 'fmTest', 'drawImage', 'no token returned', 'b', 'htHdaQwhjBhHGZ7W', 'reliable', 'hSHQaIEGRIPIYS7WMr', 'description', 'Monotype Corsiva', 'console', 'Century Gothic', 'destination', 'rgba(102, 204, 0, 0.7)', 'isPrototypeOf', 'getinfo', 'charCodeAt', 'Helvetica', 'click', 'max', 'rtcFinished', 'hostname', '.yourip.cn/fp/proxy2.html', 'Promise', 'hbRmawwXjzhFYyHFeQ', 'ceil', '_hash', 'phantomas', 'Monaco', 'callee', 'PointerEvent', 'Arial', 'i', 'cbur', 'jsonFreshUrl', 'uCMl', '_bbx', 'i.html', 'zSHlknEgRLQIGZ7eeNUA', 'Bookman Old Style', 'facebookexternalhit', 'lineHeight', 'Segoe Script', 'jmty', 'OfflineAudioContext', '; expires=Thu, 01-Jan-70 00:00:01 GMT;', 'isChrome', 'wm', 'tao', 'rv:11.0', 'setItem', 'zPHpanwXjOPFiy7WMrCfJKgjzRRmaQwhjOQrHZHS', 'zSHLIDELjIhrHq7FMZUEbXgtzVzma1Eg', 'bingpreview', 'https://static.tongdun.net/v3/', '&errorMsg=', 'TAOBAO', 'zPzDIwOejChLGMpY', '&sdkVersion=', 'isUC', 'fillRect', 'MS Outlook', 'Decryptor', 'Segoe UI Semibold', 'sampleRate', 'MYRIAD PRO', 'RequestFileSystem']

# 混淆后的 JS
with open("fm_old.js", "r", encoding="utf-8") as f:
    js_lines = f.readlines()

js = ""
for j in js_lines:
    js += j

for i in item:
    # Qo00o 需要根据你 fm_old.js 具体的字符串进行替换
    str_old = "Qo00o[{}]".format(item.index(i))
    js = js.replace(str_old, '"' + i + '"')

# 还原后的 JS
with open("fm_new.js", "w", encoding="utf-8") as f:
    f.write(js)
